from django import forms
from captcha.fields import CaptchaField
import redis

from WeiJi.settings import REDIS_HOST, REDIS_PORT
from apps.users.models import *


# 登录
class LoginForm(forms.Form):
    username = forms.CharField(required=True, min_length=5)
    password = forms.CharField(required=True, min_length=8, max_length=16)


# 注册表单验证
class RegisterPostForm(forms.Form):
    email = forms.CharField(required=True, min_length=8, max_length=25)
    username = forms.CharField(required=True, min_length=3, max_length=150)
    password1 = forms.CharField(required=True, min_length=6, max_length=16)
    confirm_password = forms.CharField(required=True, min_length=6, max_length=16)


# 修改密码
class ChangePwdForm(forms.Form):
    new_password1 = forms.CharField(required=True, min_length=5)
    new_password = forms.CharField(required=True, min_length=5)



# 用户资料
class UserInfoForm(forms.ModelForm):
    class Meta:
        model = UserProfile
        fields = ["username", "nick_name", "gender", "first_name", "last_name"]


# 更新头像
class UploadAvatarForm(forms.ModelForm):
    class Meta:
        model = UserProfile
        fields = ["avatar"]
